<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<%@ page import="com.msmall.base.util.ConstantDB" language="java"%>
<c:set var="AVALIABLE" value="<%=ConstantDB.AVALIABLE%>"></c:set>
<c:set var="UNAVALIABLE" value="<%=ConstantDB.UNAVALIABLE%>"></c:set>
<c:set var="REPLY" value="<%=ConstantDB.REPLY%>"></c:set>
<c:set var="UNREPLY" value="<%=ConstantDB.UNREPLY%>"></c:set>
<c:set var="REPLY" value="<%=ConstantDB.REPLY%>"></c:set>
<c:set var="UNREPLY" value="<%=ConstantDB.UNREPLY%>"></c:set>
<c:set var="FROM_TRANSFER" value="<%=ConstantDB.FROM_TRANSFER%>"></c:set>
<c:set var="FROM_ORIGINAL" value="<%=ConstantDB.FROM_ORIGINAL%>"></c:set>
<c:set var="COMMEND_TYPE_KLG" value="<%=ConstantDB.COMMEND_TYPE_KLG%>"></c:set>
<c:set var="SEGMENT_ID_NAV" value="<%=ConstantDB.SEGMENT_ID_NAV%>"></c:set>

<div class="know_module martop35">
	<div class="w740 fl">
		<div class="k_showdiv">
			<div class="k_showoperat">
				<a class="k_showoperatsc" href="#">收藏</a>
				<a class="k_showoperatdy" href="#">打印</a>
				<a class="k_showoperatfz" href="#">复制网址</a>
				<span class="k_showoperatp">
					字体：
					<a href="#">大</a>
					<a class="k_showoperattext" href="#">中</a>
					<a href="#">小</a>
				</span>
			</div>
			<c:choose>
				<c:when test="${not empty article}">
					<p class="k_showtitle tc">
						<span class="sH18B444"><c:out value="${article.title}"></c:out></span>
						<br>
						发布时间：<fmt:formatDate value="${article.createTime}" pattern="yyyy年MM月dd日"/>
					</p>
					<c:if test="${not empty article.contentAbstract}">
						<p class="k_showread">
							<span>导读：</span>
							<c:out value="${article.contentAbstract}"></c:out>
						</p>
					</c:if>
					<div class="k_showtext">
						<jsp:include page="/${article.htmlPath}"></jsp:include>
					</div>
				</c:when>
				<c:otherwise>
					<tiles:insertDefinition name="html.klg.article.notexist"></tiles:insertDefinition>
				</c:otherwise>
			</c:choose>
		</div>
		<tiles:insertDefinition name="html.klg.article.view.footer">
			<tiles:putAttribute name="articleid" value="${article.articleid}"></tiles:putAttribute>
			<tiles:putAttribute name="segid" value="${current.current.segmentid}"></tiles:putAttribute>
		</tiles:insertDefinition>
		
		<div class="k_showcont martop10">
			<div id="div_article_reply_new" class="k_showcomm" style="display:none"></div>
			<c:forEach var="articleReply" items="${page.items}" varStatus="status">
				<c:choose>
					<c:when test="${articleReply.enabled == AVALIABLE}">
						<div class="k_showcomm">
							<div class="paper700_notice">
								作者：<ms:user type="nickname" link="true" userid="${articleReply.userId}" nickname="${articleReply.nickname}"></ms:user>
								&nbsp;&nbsp;&nbsp;
								<fmt:formatDate value="${articleReply.createTime}" pattern="yyyy-MM-dd HH:mm"/>
							</div>
							<div class="paper750_content">
								<c:out value="${articleReply.content}"></c:out>
							</div>
						</div>
					</c:when>
					<c:otherwise>
					</c:otherwise>
				</c:choose>
			</c:forEach>
		</div>
		<div class="f_listpage">
				<div class="pagediv">
				<jsp:include page="/common/pager2.jsp"></jsp:include>
				</div>
			</div>
		<div class="k_showcont martop10">
			<div class="k_showcontnav">
				<p class="k_showcontnavbg">发表评论</p>
				<div id="div_articlReply_error" style="display:none">
				</div>
			</div>
		</div>
		<div class="k_showcomm">
			<form id="f_new_articleReply" action="<c:url value='/klg/article/reply.do' />" method="post">
				<input type="hidden" name="reply.articleid" value="${article.articleid}"/>
				<p class="tc">
					<textarea class="k_showcommform" id="articleReply_content" name="reply.content"><c:out value='${reply.content}'/></textarea>
				</p>
			</form>
			<p class="padtop10">
				<input class="but62" type="button" value="发表评论" name="" onClick="javascript:ajaxSubmitFollow('f_new_articleReply', 'div_articlReply_error', 'div_article_reply_new', 'articleReply_content');">
			</p>
		</div>
	</div>
	<div class="w250 fr">
		<p class="k_listrighnav sH705">妈妈字典</p>
		<div class="k_listrighdiv">
			<p class="k_listrighp">
				<tiles:insertDefinition name="html.wiki.babyjoinmother.preparer">
					<tiles:putAttribute name="segid" value="${segid}"></tiles:putAttribute>
					<tiles:putAttribute name="segType" value="${SEGMENT_ID_NAV}"></tiles:putAttribute>
				</tiles:insertDefinition>
			</p>
		</div>
	</div>
</div>

<script>
function ajaxSubmitFollow(formid, errorid, newid, contentid){
	$("#"+errorid).html();
	$("#"+errorid).css("display", "none");
	$.ajax({
		type : "POST",
		url : $("#"+formid).attr('action'),
		data : $("#"+formid).serialize(),
		dataType:"xml", 
		timeout:20000,
		success : function(data){
			if($(data).find('result').text().toUpperCase().indexOf("TRUE") < 0){
				$("#"+errorid).html($(data).find('content').text());
				$("#"+errorid).css("display", "block");
			}else{
				var content = "<div class='paper700_notice'>作者：<c:out value='${nickname}'/>&nbsp;&nbsp;&nbsp;"+ formatDate(new Date(), "yyyy-MM-dd HH:mm"); 
				content = content + "</div><div class='paper750_content'>";
				content = content + "您的回复正等待审核....<br/><br/>";
				content = content + $("#"+contentid).val();
				content = content + "</div>";
				$("#"+newid).html(content);
				$("#"+newid).css("display", "block");
				$("#"+contentid).val('');
			}
		},
		error: function(){
		}
	});
}
</script>